import 'package:flutter/material.dart';
import 'package:get/get.dart';

class DetailView extends StatelessWidget {
  const DetailView({super.key});


  _buildBackListTileRow(Map? val) {
    return val == null
        ? Container()
        : ListTile(
      title: Text("传值 id = ${val["id"]}"),
      subtitle: const Text('Get.back(result: {"success": true}'),
      onTap: () => Get.back(result: {"success": true}),
    );
  }

  @override
  Widget build(BuildContext context) {

    final Map<String, dynamic>? details = Get.arguments as Map<String, dynamic>?;
    final Map<String, String?> parameters = Get.parameters;

    return Scaffold(
      appBar: AppBar(
        title: const Text("详情页"),
      ),
      body: ListView(
        children: [
          ListTile(
            title: const Text("导航-返回"),
            subtitle: const Text('Get.back()'),
            onTap: () => Get.back(),
          ),
          _buildBackListTileRow(details),
          _buildBackListTileRow(parameters),
        ],
      ),
    );
  }
}
